const vm = require('vm');

const sandbox = {
  foo: 'bar'
};

const code = 'debugger;console.log(this);';
vm.createContext({sandbox});
vm.runInNewContext(code, sandbox);  // 应该打印 "bar"